var ul=document.querySelector('main>ul')
var xhr=new XMLHttpRequest()
xhr.open('get','http://chst.vip:1234/api/getcoupon')
xhr.send()
xhr.onreadystatechange=function(){
    if(xhr.status===200&&xhr.readyState===4){
        var x=JSON.parse(xhr.responseText).result
        console.log(x)
        var html=""
        x.forEach(item => {
            html+=` <li value=${item.couponId}>
           <img src=" ${item.couponImg}">
            <p>${item.couponTitle}</p>
        </li>`
        });
        ul.innerHTML=html
        var lis=document.querySelectorAll('main>ul>li')
        console.log(lis)
        lis.forEach((iteml)=>{
            iteml.onclick=function(){
               var couponid=iteml.getAttribute('value')
               console.log(couponid)
               location.href=`./6跳转页.html?couponid=${couponid}`
            }
        })
    }
}
//书写返回index.html功能
var fanhui=document.querySelector('header>a')
fanhui.onclick=function(){
    location.href="../index.html"
}